<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script src="webjars/jquery/3.6.4/jquery.min.js"></script>
  <link href="webjars/bootstrap/5.2.3/css/bootstrap.min.css" rel="stylesheet">
    <script>
        $(function (){
            $.get(
                "findRoles",
                {uid:$("[name='uid']").val()},
                function (data){
                    console.log(data);
                    for(var i in data){
                        $("[name='chk'][value='"+data[i]+"']").prop("checked",true);
                    }
                }
            )
        })

    </script>
</head>
<body>
    <div class="container">
         <form method="post" th:object="${user}">
             <input type="hidden" name="uid" th:value="*{uid}">
             账号：<input type="text" name="username" th:value="*{username}">
             <span id="sp1"></span><br>
             密码：<input type="password" name="password" th:value="*{password}"><br>
             姓名：<input type="text" name="realname" th:value="*{realname}"><br>
             性别：<input type="radio" name="sex" th:value="0" th:checked="*{sex==0}"> 男
             <input type="radio" name="sex" th:value="1" th:checked="*{sex==1}">女<br>
             生日：<input type="text" name="birthday" th:value="*{#dates.format(birthday,'yyyy-MM-dd')}"> <br>
             角色：<input type="checkbox" name="chk" th:each="role:${roles}" th:value="${role.rid}" th:text="${role.rname}">
           <br>
               <button class="btn btn-success">提交</button>
         </form>
    </div>
</body>
</html>
